package com.yy.tkmybatis.service.impl;

import com.yy.tkmybatis.entity.ProductInfo;
import com.yy.tkmybatis.mapper.ProductInfoMapper;
import com.yy.tkmybatis.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProductInfoServiceImpl implements ProductInfoService {
    @Resource
    private ProductInfoMapper productInfoMapper;
    @Override
    public ProductInfo getOne(ProductInfo productInfo) {
        ProductInfo productInfo1 = productInfoMapper.selectOne(productInfo);
        return productInfo1;
    }

    @Override
    public Integer saveProductInfo(ProductInfo productInfo) {
        int i = productInfoMapper.insert(productInfo);

        return i;
    }

    @Override
    public List<ProductInfo> getList() {
        Example example = new Example(ProductInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andBetween("productPrice",4,12);
        List<ProductInfo> productInfoList = productInfoMapper.selectByExample(example);
        return productInfoList;
    }
}
